/*
 * Main.cpp - Stack Example - using the Stack template class
 *
 *  Created on: Mar 7, 2013
 *      Author: Anthony Varghese
 */

#include <iostream>

#include "Stack.cpp" // OK because we are using templates
#include "Queue.cpp"

using std::cin;
using std::cout;
using std::endl;
using SavitchStack::Stack;
using SavitchQueue::Queue;

int main(){
	cout << "CSIS 237 Lab 8 - Stacks and Queues" << endl;
    char next, ans;

    do {
        cout << "Enter a line of text:     ";

        cin.get(next);
        Stack<char> s;
        Queue<char> q;
        while (next != '\n') {
            s.push(next);
            q.add( next );
            cin.get(next);
        }

        cout << "Written backward that is: ";
        bool palindrome = true;
        while ( ! s.isEmpty( ) ) {
        	    char cs  = s.pop();
       	    char cq = q.remove();

        	   if(palindrome)
        	    palindrome = (cs == cq);

           cout << cs;
        }
        if (palindrome)
        	   cout << " - a palindrome!!";
        else
        	   cout << " - not a palindrome.";
        cout << endl;
        cout << endl;

        cout << "Again?(y/n): ";
        cin >> ans;
        cin.ignore(10000, '\n');
    }while (ans != 'n' && ans != 'N');
}
